<!-- 
    The Code By DayiTech FrontEnd
    Author:Han
    Created At 2018/05/05 14:20:39
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>排行榜</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/app.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <style>
        body{
            padding:0;
            margin:0;
            background-color:white;
        }
        #app{
            display: grid;
            grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
        }
        .main-box{
            border-right: 1px dashed #cccccc;
        }
        .main-box:last-child{
            border-right: none;
        }
        .el-main{
            padding:10px;
        }
        .brand_logo{
            max-width:100px;
            max-height:80px;
            margin-top:20px;
        }
        .title-box{
            text-align: center;
            overflow: hidden;
        }
        .title{
            font-size:18px;
            line-height:60px;
        }
        .title b{
            font-size:20px;
        }
        .rank-box{
            margin-bottom: 0;
            padding-bottom:0;
        }
        .rank-box .rank-body{
            margin:0 auto;
            height: 140px;
            border-radius: 16px;
            background-color: #f2f6fc;
            box-shadow: 0px 4px 10px 0 rgba(151, 151, 151, 0.35);
        }
        .rank-box .rank-body:nth-child(1),.rank-box .rank-body:nth-child(2),.rank-box .rank-body:nth-child(3){
            height:80px;
        }
        .el-progress-bar__outer{
            background-color:#f2f6fc;
        }

        .rank-box .rank-body:nth-child(1),.rank-box .rank-body:nth-child(2),.rank-box .rank-body:nth-child(3){
            overflow: hidden;
            margin-bottom:10px;
        }
        .rank-box .rank-body:nth-child(1) .rank-title,.rank-box .rank-body:nth-child(2) .rank-title,.rank-box .rank-body:nth-child(3) .rank-title{
            font-size:23.2px;
            display: block;
            overflow: hidden;
        }
        .rank-box .rank-body:nth-child(2){
            background-color: #eeeeee;
        }
        .rank-box .rank-body:nth-child(2) .el-progress-bar__outer{
            background-color: #eeeeee;
        }
        .rank-box .rank-body:nth-child(1) .rank-title{
            color: #f56c6c;
        }
        .rank-box .rank-body:nth-child(2) .rank-title{
            color: #f5c66c;
        }
        .rank-box .rank-body:nth-child(3) .rank-title{
            color: #6cc3f5;
        }
        .rank-box .rank-body:nth-child(1) .rank-title span,.rank-box .rank-body:nth-child(2) .rank-title span,.rank-box .rank-body:nth-child(3) .rank-title span{
            line-height:80px;
        }
        .rank-box .rank-body:nth-child(1) .rank-title b,.rank-box .rank-body:nth-child(2) .rank-title b,.rank-box .rank-body:nth-child(3) .rank-title b{
            font-size:50px;
            line-height:80px;
        }
        .rank-box .rank-body:nth-child(1) .rank-img,.rank-box .rank-body:nth-child(2) .rank-img,.rank-box .rank-body:nth-child(3) .rank-img{
            width:50px;
            height:50px;
            margin-top:8px;
        }
        .rank-box .rank-body:nth-child(1) .rank-img img,.rank-box .rank-body:nth-child(2) .rank-img img,.rank-box .rank-body:nth-child(3) .rank-img img{
            max-width:50px;
            max-height:65px;
        }
        .rank-box .rank-body:nth-child(1) .rank-girard,.rank-box .rank-body:nth-child(2) .rank-girard,.rank-box .rank-body:nth-child(3) .rank-girard{
            font-size:22px;
            margin-bottom:10px;
            margin-top:10px;
        }
        .rank-box-four .rank-body{
            overflow: hidden;
            margin:0 auto;
            height: 70px;
            border-radius: 16px;
            background-color: #f2f6fc;
            box-shadow: 0px 4px 10px 0 rgba(151, 151, 151, 0.35);
            margin-bottom:10px;
        }
        .rank-box-four .rank-body .rank-title{
            font-size:14.2px;
            display: block;
            overflow: hidden;
            color: #6cc3f5;
        }
        .rank-box-four .rank-body .rank-title span{
            line-height:70px;
        }
        .rank-box-four .rank-body .rank-title b{
            font-size:26px;
            line-height:76px;
        }
        .rank-box-four .rank-body .rank-img{
            margin-top:15px;
        }
        .rank-box-four .rank-body .rank-img img{
            max-width:50px;
            max-height:50px;
        }
        .rank-box-four .rank-body .rank-girard{
            font-size:18px;
            margin-bottom:10px;
            margin-top:10px;
        }
        .rank-box-four .rank-body:nth-child(odd) {
            background-color: #eeeeee;
        }
        .rank-box-four .rank-body:nth-child(odd) .el-progress-bar__outer{
            background-color: #eeeeee;
        }
    </style>
</head>
<body>
    <div id="app">
        <div v-for="item in dataMain" class="main-box">
            <el-header height="90">
                <el-row class="title-box">
                    <span class="title">
                        <b>@{{ item.cate_type }}</b> 热销榜</span>
                </el-row>
            </el-header>
            <el-main class="rank-box">
                <el-row class="rank-body">
                    <el-col :span="3" :offset="1">
                        <div class="rank-title">
                            <b>1</b>
                        </div>
                    </el-col>
                    <el-col :span="5" :offset="1">
                        <div class="rank-img">
                            <img :src="item.first[0].image">
                        </div>
                    </el-col>
                    <el-col :span="12" :offset="1">
                        <p class="rank-girard">@{{ item.first[0].girard }}</p>
                        <el-progress :show-text="false" :stroke-width="10" :percentage="item.first[0].percentage" status="exception"></el-progress>
                    </el-col>
                    <el-col :span="1"></el-col>
                </el-row>
                <el-row class="rank-body">
                    <el-col :span="3" :offset="1">
                        <div class="rank-title">
                            <b>2</b>
                        </div>
                    </el-col>
                    <el-col :span="5" :offset="1">
                        <div class="rank-img">
                            <img :src="item.second[0].image" alt="" srcset="">
                        </div>
                    </el-col>
                    <el-col :span="12" :offset="1">
                        <p class="rank-girard">@{{ item.second[0].girard }}</p>
                        <el-progress :show-text="false" :stroke-width="10" :percentage="item.second[0].percentage" color="#f5c66c"></el-progress>
                    </el-col>
                    <el-col :span="1"></el-col>
                </el-row>
                <el-row class="rank-body">
                    <el-col :span="3" :offset="1">
                        <div class="rank-title">
                            <b>3</b>
                        </div>
                    </el-col>
                    <el-col :span="5" :offset="1">
                        <div class="rank-img">
                            <img :src="item.third[0].image" alt="" srcset="">
                        </div>
                    </el-col>
                    <el-col :span="12" :offset="1">
                        <p class="rank-girard">@{{ item.third[0].girard }}</p>
                        <el-progress :show-text="false" :stroke-width="10" :percentage="item.third[0].percentage" color="#6cc3f5"></el-progress>
                    </el-col>
                    <el-col :span="1"> </el-col>
                </el-row>
            </el-main>
            <el-main class="rank-box-four">
                <el-row class="rank-body" v-for="data in item.data">
                    <el-col :span="3" :offset="1">
                        <div class="rank-title">
                            <b>@{{ data.id }}</b>
                        </div>
                    </el-col>
                    <el-col :span="6" :offset="1">
                        <div class="rank-img">
                            <img :src="data.image">
                        </div>
                    </el-col>
                    <el-col :span="12" :offset="1">
                        <p class="rank-girard">@{{ data.girard }}</p>
                        <el-progress :show-text="false" :stroke-width="10" :percentage="data.percentage" color="6cc3f5"></el-progress>
                    </el-col>
                </el-row>
            </el-main>
        </div>
    </div>
</body>
<script>
    var cdn_name = "{{ env('CDN_DOMAIN_NAME') }}";
    var app = new Vue({
        el:"#app",
        data(){
            return{
                dataMain:[],
            }
        },
        mounted(){
            let self = this;
            $.ajax({
                headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
                url: '/ranking/ranking-list-dataX',
                type: 'get',
                data: {
                },
                dataType: 'json',
                success: function(res) {
                    if(res.result.success == true){
                        const content = res.content;
                        let option = [];
                        for(var value in content){
                            let sum = content[value].sum_num;
                            let checkFour = 0;
                            let fourData = [];
                            for(let data in content[value].info){
                                if(checkFour >2){
                                    fourData.push({id:checkFour+1,girard:content[value].info[data].girard,image:self.checkImg(content[value].info[data].img_path),percentage:(Number(Number((200*Number(content[value].info[data].num)/Number(sum))).toFixed(0))+2)});
                                }
                                checkFour ++;
                            }
                            option.push({
                                cate_type:content[value].title,
                                first:[{
                                    girard:content[value].info[0].girard,
                                    percentage:Number(((300*Number(content[value].info[0].num)/Number(sum))).toFixed(0)),
                                    image:self.checkImg(content[value].info[0].img_path)
                                }],
                                second:[{
                                    girard:content[value].info[1].girard,
                                    percentage:Number(((300*Number(content[value].info[1].num)/Number(sum))).toFixed(0)),
                                    image:self.checkImg(content[value].info[1].img_path)
                                }],
                                third:[{
                                    girard:content[value].info[2].girard,
                                    percentage:Number(((300*Number(content[value].info[2].num)/Number(sum))).toFixed(0)),
                                    image:self.checkImg(content[value].info[2].img_path)
                                }],
                                data:fourData
                            })
                        }
                        self.dataMain = option;
                        // let data = res.content.list;
                        // let sum = res.content.num;
                        // self.cate_type = res.content.name
                        // self.first[0].girard = data[0].girard;
                        // self.first[0].image = data[0].img_path;
                        // self.first[0].percentage = Number(((200*Number(data[0].num)/Number(sum))).toFixed(0));
                        // self.second[0].girard = data[1].girard;
                        // self.second[0].image = data[1].img_path;
                        // self.second[0].percentage = Number(((200*Number(data[1].num)/Number(sum))).toFixed(0));
                        // self.third[0].girard = data[2].girard;
                        // self.third[0].image = data[2].img_path;
                        // self.third[0].percentage = Number(((200*Number(data[2].num)/Number(sum))).toFixed(0));
                        // let checkFour = 0;
                        // let fourData = [];
                        // for(let value of data){
                        //     if(checkFour >2){
                        //         fourData.push({id:checkFour+1,girard:value.girard,image:self.checkImg(value.img_path),percentage:(Number(Number((200*Number(value.num)/Number(sum))).toFixed(0))+1)});
                        //     }
                        //     checkFour ++;
                        // }
                        // self.data = fourData;
                        setInterval(function(){
                            window.location.reload();
                        }, 600000);
                    }
                }
            });
        },
        methods:{
            checkImg(src){
                if(src == "请在操作选择图片"){
                    return cdn_name+"/bee/default.jpg"
                }else{
                    return src
                }
            }
        }
    })
</script>
</html>